package com.hjq.mallorder.entity.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;
import java.util.List;

/**
 * @auther HJQ
 */

public class OrderConfirmVO {
   //地址信息
 @Getter@Setter
    private List<MemberRecieveEntity> address;
    //购物项    private List<MemberRecieveEntity> address;
    @Getter@Setter
    private List<OrderItemVO> items;
    //积分' @Getter@Setter
    @Getter@Setter
    private Integer integration;
    //订单总额
    private BigDecimal total;
    //应付总额
    private BigDecimal payPrice;
    @Getter@Setter
    private  String orderToken;
    //总商品数量
    private Integer totalCount;

    public Integer getTotalCount() {
        Integer count = 0;
        for (OrderItemVO item : items) {
             count += item.getCount();
        }
        return count;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public BigDecimal getTotal() {
  BigDecimal sum=new BigDecimal(0);
  for (OrderItemVO item : items) {
   sum=sum.add(item.getPrice().multiply(new BigDecimal(item.getCount())));
  }
  return sum;
 }

 public void setTotal(BigDecimal total) {
  this.total = total;
 }

 public BigDecimal getPayPrice() {
  return payPrice;
 }

 public void setPayPrice() {
  this.payPrice = getTotal();
 }

    @Override
    public String toString() {
        return "OrderConfirmVO{" +
                "address=" + address +
                ", items=" + items +
                ", integration=" + integration +
                ", total=" + total +
                ", payPrice=" + payPrice +
                ", orderToken='" + orderToken + '\'' +
                '}';
    }
}
